home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr03 / datasht.zip / README.TXT < prev    next >
Text File  |  1993-07-01  |  9KB  |  191 lines

  1. DATASHT.DOT -- An interactive form by John Hill
  2.  
  3. The macros in DATASHT.DOT illustrate features that make an interactive form 
  4. with many fields a pleasure to use.  This example is a single page datasheet 
  5. with 82 fields.  By using FieldChars instead of bookmarks, the limit of 2000 
  6. fields is exploited to allow up to 24 completed datasheets in a single 
  7. document (82 x 24 = 1968).  Dials are provided to allow the user to jump 
  8. directly to any desired datasheet and field.  An option is provided to 
  9. extract data from previously created .TXT files.  All fields are length 
  10. checked.
  11.  
  12. Viewing the macros:
  13.  
  14. DATASHT.DOT includes an AutoOpen macro that doesn't provide the option to 
  15. edit the macros (this is intentional).  There is a back door, however.  After 
  16. loading Word, select FileTemplate and attach DATASHT.DOT.  DATASHT.DOT must 
  17. be in the "programdir" or "DOT-PATH" listed in the [Microsoft Word 2.0] 
  18. section of your WIN.INI file or in the current directory.
  19.  
  20. Now you can use ToolsMacro to View (Edit) the macros.  Select the Show 
  21. Template Macros option if it isn't already selected.
  22.  
  23. The following macros will be listed:
  24.  
  25. AutoNew
  26. AutoOpen
  27. CreateDataSheet
  28. Echo
  29. FillinManually
  30. InsertFieldLocationData
  31. LoadSheetsFromTextFile
  32. MoreInformation
  33.  
  34. The following are brief descriptions of the macros:
  35.  
  36. AutoNew:
  37.  
  38. Maximizes the document window, adjusts the view so that the width of the form 
  39. is visible and so that the form appears as it will when printed and presents 
  40. the "Data Sheet Main Menu" dialog box.  The Echo macro is used to prevent the 
  41. user from seeing the activity before the menu is presented.  The Data Sheet 
  42. Main Menu items and actions are as follows:
  43.  
  44.                ITEM                              ACTION
  45.  
  46.      Print a Blank Data Sheet             Runs CreateDataSheet, prints the
  47.                                           datasheet and then deletes it.
  48.  
  49.      Fillin or Edit Data Sheets           Runs FillinManually
  50.  
  51.      Create Data Sheets From Text File    Runs LoadSheetsFromTxtFile
  52.  
  53.      Print Data Sheets                    Runs FilePrint
  54.  
  55.      More Information                     Runs MoreInformation
  56.  
  57.      Exit                                 Runs FileClose and Exits the
  58.                                           document
  59.  
  60. AutoOpen:
  61.  
  62. Runs AutoNew
  63.  
  64. CreateDataSheet:
  65.  
  66. If the subroutine CreateDataSheet(CopyLast) is called, a blank datasheet is 
  67. created if the argument 0 is passed or the last datasheet is copied if the 
  68. argument 1 is passed.  A blank datasheet is created if CreateDataSheet is 
  69. called directly.
  70.  
  71. A blank datasheet is created by inserting it from the glossary.  The blank 
  72. datasheet includes FieldChars in each of the 82 fields.  The user is 
  73. requested to "PLEASE BE PATIENT" because of the time required to perform the 
  74. following operations:
  75.  
  76. 1. Repaginate the document to update the page count.
  77. 2. Toggle the Field Display to hide the FieldChars.
  78.  
  79. The subroutine Echo(n) is used to hide the above activity from the user and 
  80. speed-up operation.
  81.  
  82. Echo:
  83.  
  84. This macro is contained in the file VGECHO.EXE available in Lib 2 of the 
  85. PROGMSA forum.  If the subroutine Echo(n) is called, document window updating 
  86. is suspended if the argument 0 is passed, Word application window updating is 
  87. suspended if the argument -1 is passed or updating is resumed if the argument 
  88. 0 is passed.  If Echo is called directly, updating is resumed.
  89.  
  90. FillinManually:
  91.  
  92. This macro is the heart of DATASHT.DOT.  It's built around a For..Next loop 
  93. that presents the "Data Sheet Navigation" dialog box and is incremented if 
  94. the "Next Field" button or Enter is depressed or is decremented if the "Prev 
  95. Field" button is depressed.  Each time the loop is incremented or 
  96. decremented, the cursor is positioned in the next or previous field.
  97.  
  98. The first line of Sub MAIN calls subroutine LoadFieldTable, immediately 
  99. following Sub MAIN.  Subroutine LoadFieldTable loads arrays that contain the 
  100. name, length, prompt and position of each of the 82 fields.
  101.  
  102. The "GoTo:" dialog box is presented if the "Cancel" button on the "Data Sheet 
  103. Navigation" dialog box is depressed.  The "GoTo: dialog box is similar to the 
  104. dialog box that is presented by the Edit Go To command except that the option 
  105. to go directly to another page (datasheet in this case) is also provided.  
  106. When a new field is selected, the cursor is first moved to the line the field 
  107. is on and then incremented the required number fields to the right, instead 
  108. of jumping directly to a bookmark as would be done if bookmarks were used.  
  109. Unlike bookmarks, the use of FieldChars allows the same names to be used 
  110. regardless of page.  The ability to jump directly to a field up to 2000 
  111. fields away is unique to this method.  The only difference if another page is 
  112. selected is that the cursor is first positioned at the beginning of the first 
  113. line of the datasheet on the new page.
  114.  
  115. InsertFieldLocationData:
  116.  
  117. This macro was used create the lines necessary to load arrays LineNo() and 
  118. FieldsRight() in macro "FillinManually".  It first determines the values of 
  119. LineNo(n) and FieldsRight(n) for each field in the datasheet and then inserts 
  120. the lines necessary to load these arrays at the end of the current document.  
  121. Use the following procedure to give it a try:
  122.  
  123. 1. Follow the procedure in "Viewing the macros:"
  124. 2. Use "ToolsMacro" to run "CreateDataSheet" to create a blank datasheet.
  125. 3. Use "ToolsMacro" to run "InsertFieldLocationData".
  126.  
  127. The results obtained were cut from the document, pasted to the end of macro 
  128. "FillinManually" and edited to the present form.  The same macro may be used 
  129. to do the same for ANY form with fields.  Simply replace 82 where ever it 
  130. appears with the number of fields in YOUR form.
  131.  
  132. CAUTION:  If your form contains table rows that are less than the normal 
  133. height, some values of LineNo() may need to be changed.  This was the case 
  134. with the datasheet in DATASHT.DOT.  Apparently, there are two line counts: 
  135. the one created when a document is Paginated and that is listed in the status 
  136. bar and read by SelInfo(10) and the one used by the EditGoTo command.  They 
  137. are NOT always the same.
  138.  
  139. LoadSheetsFromTxtFile:
  140.  
  141. The datasheet in DATASHT.DOT is based on an existing WordPerfect 5.1 form 
  142. used extensively in the past.  Hundreds of WordPerfect 5.1 documents exist 
  143. that contain several pages of text followed by completed datasheets.  
  144. "LoadSheetsFromTxtFile" was written in case there is ever a desire to create 
  145. new Word datasheets from old WordPerfect 5.1 datasheets.  It is much faster 
  146. to extract data from a file directly than to insert the file and copy the 
  147. information from one location to another as was done in earlier versions of 
  148. the macro.  First the file containing the desired datasheets must be opened 
  149. in WordPerfect and the desired datasheets selected and saved in a Text file.  
  150. The procedure is in macro "MoreInformation" and may be printed.  Saving the 
  151. desired datasheets in a Text file places a carriage return and line feed at 
  152. the end of each line and removes all formatting information so that the 
  153. WordBasic string functions may be used to locate the data in the old 
  154. datasheets based on a knowledge of the position and length of the desired 
  155. data in a line.
  156.  
  157. The InsertFile dialog box is used to obtain the name of the text file.  The 
  158. subroutine Echo(n) is used to hide uninteresting activity from the user and 
  159. speed-up operation.
  160.  
  161. Subroutine LocateNextLine(Text$, CR) is used to place the contents of a 
  162. desired line, located using the value of Text$, in Line$ and set CurPos at 
  163. the location of the data or at the beginning of the next line.  The syntax is 
  164. explained in detail in the macro.  An error code is returned if the file 
  165. opened is not a text file.
  166.  
  167. Text$ is replaced with the desired data from Line$ using the WordBasic Mid$() 
  168. function and the value of CurPos.
  169.  
  170. Subroutine CopyToNextField positions the cursor at the next field in the new 
  171. Word datasheet, selects the current contents of the field and inserts Text$ 
  172. in its place.  The syntax is explained in detail in the macro.
  173.  
  174. MoreInformation:
  175.  
  176. The starting point for macro "MoreInformation" was the "Instructions" macro 
  177. in LETMODBK.DOT, variations of which are also found in LETBLOCK.DOT, 
  178. LETMDSEM.DOT and LETPERSN.DOT.  The only added touch is the ability to print 
  179. the procedure listed for creating Text files from datasheets contained in 
  180. WP51 documents.
  181.  
  182. The reason it was necessary to include a copy of Subroutine Echo(n) is that 
  183. the lines to be printed are inserted into a "FileNewDefault", based on 
  184. NORMAL.DOT, which may not include a copy of macro Echo.
  185.  
  186. Questions of Comments:
  187.  
  188. Please feel free to address questions or comments to John Hill, 73567,2054, 
  189. in Section 2 of the PROGMSA CompuServe forum.
  190.  
  191.